﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClusterLibrary
{
    public abstract class ClusterView
    {
        protected Cluster cluster;
        protected Shape clusterShape;

        public Cluster Cluster
        {
            get 
            {
                return this.cluster;
            }
        }

        public ClusterView(Cluster cluster, Shape clusterShape)
        {
            this.cluster = cluster;
            this.clusterShape = clusterShape;
        }

        public void moveCluster(int dx, int dy)
        {
            this.clusterShape.moveShape(dx, dy);
            foreach (ClusterView subclass in this.cluster.Subclasses)
            {
                subclass.moveCluster(dx, dy);
            }
        }

        public void drawCluster(Graphics g)
        {
            this.clusterShape.drawShape(g);
            foreach (ClusterView subclass in this.cluster.Subclasses)
            {
                subclass.drawCluster(g);
            }
        }

        public bool isActive(int x, int y)
        {
            return this.clusterShape.isActive(x, y);
        }

        public ClusterView getSubclass(int x, int y)
        {
            foreach (ClusterView subclass in this.cluster.Subclasses)
            {
                if (subclass.isActive(x, y)) return subclass;
            }

            return null;
        }
        public abstract void addSubclass();
        public abstract void addSubclass(ClusterView subclass);
        public abstract void addSubclass(Cluster subclass);

        public abstract void removeSubclass(ClusterView subclass);
    }
}
